package com.witmore.skyline.web.service.third.yjx.client;

import com.alibaba.fastjson.JSONObject;
import com.witmore.skyline.web.service.third.constants.ApiClientCommonConstant;
import com.witmore.skyline.web.service.third.yjx.dto.CameraDTO;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;

import java.util.List;

import static java.lang.String.format;

/**
 * Description: ApiCameraClient
 * Author: 豆子高
 * Date: 2025/2/26 15:21
 */
@Service
public class ApiCameraClient {
    /**
     * 获取摄像头接口
     */
    public List<CameraDTO> fetchCameraList(String deviceSn) {
        String urlString = format(ApiClientCommonConstant.API_PREFIX + ApiClientCommonConstant.GET_CAMERA_LIST_PATH,
                TokenCache.getToken(), deviceSn);
        String responseResult = ApiClient.responseHandle(urlString, "获取摄像头列表接口");
        if (ObjectUtils.isEmpty(responseResult)) {
            return null;
        }
        return JSONObject.parseArray(responseResult, CameraDTO.class);

    }


}
